import React,{useEffect} from 'react'
import {useHistory,useLocation} from "react-router-dom"
function dhtoken(Com){
 return function dhtoken(props) {
let hsitory=useHistory()
let location=useLocation()
useEffect(()=>{
    if(location.pathname!=='/login'){
        let token=localStorage.getItem('token')
        if(!token){
            hsitory.push('/login')
        }
    }

})
  return (

<>
<Com {...props}></Com>
</>
  )
}
}
export default dhtoken
